<template>
	<view class="all-box containers">
		<hx-navbar :config="navConfig"></hx-navbar>
		<!-- 404页面 -->
		<view  class="noData" v-if="netWorkType == 'none'">
			<noData @handle="refresh"></noData>
		</view>
		<view  v-if="netWorkType != 'none'">
		
			<view  class="container tui-skeleton">
				<view @click="detail(item)" v-for="(item,index) in data.list" class="business-box margin-all15 bg-white margin-bottom15 border-radius8">
					<view class="flex-start-box font14 font-bold padleft15 padright15 padtop15">
						<view class="flex-item title font-gray">公司名称</view>
						<view class="flex-item padleft15">{{item.company_name}}</view>
					</view>
					<view class="flex-start-box font14 font-bold padleft15 padright15 padtop15">
						<view class="flex-item title font-gray">联系人</view>
						<view class="flex-item padleft15">{{item.contact_name}}</view>
					</view>
					<view class="flex-start-box font14 font-bold padleft15 padright15 padtop15">
						<view class="flex-item title font-gray">联系电话</view>
						<view class="flex-item padleft15">{{item.mobile}}</view>
					</view>
					<view class="flex-start-box font14 font-bold padleft15 padright15 padtop15 padbottom15">
						<view class="flex-item title font-gray">申请状态</view>
						<view class="flex-item body-color padleft15">{{item.check_estate_name}}</view>
					</view>
					<view v-if='item.check_estate==3' style="color:#F44336;padding: 20rpx;" >
						{{item.reason||''}}
					</view>
				</view>
				<!-- 下面的线 -->
				<!-- <tui-divider width="60%" divideColor="red" bgcolor="#F7F7F7">我也是有底线的</tui-divider> -->
				<view style="padding-bottom:60rpx">
				</view>
			</view>
			<view class="fixed-foot ">
				<view @tap="add" class="inner bg-body font-white border-radius25 btn-box">
					<view class="font16">申请注册</view>
				</view>
				<view @tap="bind" class="inner bg-body font-white border-radius25 btn-box">
					<view class="font16">绑定已注册账号</view>
				</view>
			</view>
		</view>
		<!-- 悬浮优惠卷 -->
		<!-- <view class="coupon-btn-flex" @click="toList('coupon')">
			<image :src="OSS_HOST+'LH_index/index_coupon.png'" mode="widthFix" style="width: 100%;"></image>
			
		</view> -->
		<!-- 提示弹框 -->
		<!-- <tui-tips ref="toast"></tui-tips> -->
		
		<!-- 登录弹框 -->
		
		
		<!-- <uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" /> -->
		<uni-popup ref="checkedModel" type="center" custom="true" >
			<view class="check-tab">
				<view class="title">
					商户审核
				</view>
				<view class="check-estate">
					<text>审核:</text>
					 <switch :checked="check_estate" @change="changeEstate"/>
					<text>{{check_estate?'通过':'不通过'}}</text>
					
				</view>
				<view v-if="check_estate == false">
					<text>理由</text>
					<textarea name="reason" v-model="reason" id=""  rows="3" style="border: 2rpx solid; width: 650rpx; height: 100rpx;"></textarea>
					<!-- <input type="textarea" v-model="reason"> -->
				</view>
				<view class="btn">
					<view class="btn-border" @tap="$refs['checkedModel'].close()">取消</view>
					<view class="btn-border btn-queren" @tap="check">确认</view>
					
				</view>
			</view>	
			
		</uni-popup>
		<!-- 登录弹框 -->
		<uni-popup-vlogin id="popupvLogin" ref="popupvLogin" type="bottom" />
	</view>
</template>
<script>
	// 骨架屏
	import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
	// 气泡框
	// import bubblePopup from '@/components/tui-bubble-popup/tui-bubble-popup.vue'
	// 引入最下面的线
	// import tuiDivider from "@/components/divider/divider.vue"
	//下拉组件
	// import uniLoadMore from '@/components/uni-load-more.vue';
	// import tuiListCell from "@/components/list-cell/list-cell"
	// import uniPopup from '@/components/uni-popup/uni-popup.vue'
	// import tuiButton from '@/components/button/button.vue'
	// import hxNavbar from '@/components/hx-navbar/hx-navbar'
	// import tuiModal from "@/components/modal/modal"
	import Vue from 'vue'
	import jsCookies from '@/node_modules/js-cookie'
	import store from '@/store/index.js';
	// 公共底部
	// import btabbar from '@/components/indexBottomTable/bottomtabbar.vue'
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import {
		mapGetters
	} from 'vuex';

	// 按需加载
	export default {


		components: {
			// tuiModal,
			uniPopup,
			// btabbar,
			// tuiListCell,
			// tuiDivider,
			// uniLoadMore,
			// tuiButton,
			// bubblePopup,
			// tuiSkeleton,
			// hxNavbar
		},
		data() {
			return {
				
				isTop:0,
				navConfig:{
					// business-enter-nav.png
					backgroundImg:'https://xoimg.aiouning.com/static/img/business-enter-nav.png',
					// title:'申请列表',
					color:'#fff',
					fontSize:12,
					back:true,
					height:55
					
					
				},
				
				// 图片链接站点
				OSS_HOST: 'https://xoimg.aiouning.com/static/',
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了',
					contentfirst: "暂无数据"
				},
				reason:'',
				check_estate:false,
				id:'',
				
				
				
				message: "",
				
				//接口数据
				data: {
					
					list: []
					
					
				},
			
				cartsListHeight: 400, //动态高度
				calcullateHeight: 400, //固定高度，计算需要
				current: 0,
			
				
				curr_page: 0,
				last_page: 0,

				
				// 骨架屏
				skeletonShow: true
			}
		},

		computed: {
			//注册网络状态
			...mapGetters(['netWorkType', 'loginStatus'])
		},
		onPageScroll: function(e) {
		
			if (e.scrollTop >300) {
				this.isTop = 1
			} else {
				this.isTop = 0
			}
		},
		onLoad: function(e) {

			let that = this;
			console.log(e,'123132131')
			//that.$refs.popupvLogin.open()
			//  高度自适应
			uni.getSystemInfo({
				success: function(res) {
					// console.log(res)
					let calc = res.windowHeight;
					that.winHeight = calc;		
				}
			});
			//#ifdef  MP-WEIXIN
				that.navHeight = 44;
			//#endif
			if (typeof e != "undefined") {
				if (typeof e.q != "undefined") {
					// 扫码进入
					let scene = decodeURIComponent(e.q)
					// store.dispatch('setPromotionId', this.getQueryVariable('promotion_id', scene))
					let inviteUserId = this.$service.getQueryVariable('user_id', scene)
					// 邀请人id
					uni.setStorageSync('inviteUserId', inviteUserId);
					// 专属 推广员
					let assertUserId = this.$service.getQueryVariable('assert_user_id', scene)
					uni.setStorageSync('assertUserId', assertUserId);
					// console.log(assertUserId,'assertUserId*****')
					// that.adv_channel = adv_channel
				}
				
			
			}
		},
		//页面初始
		onShow() {
			this.curr_page = 0
			
			this.getList()
			
			
			
			

		},
		onPullDownRefresh: function() {
			//下拉刷新的时候请求一次数据
			//console.log(11)
			this.curr_page = 0
			// this.loadingType = 3;				
			// this.getList();
			
			
		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			//为了更加清楚的看到效果，添加了定时器
			//console.log(this.curr_page)

			if (this.curr_page >= this.last_page) {
				uni.showToast({
					icon: 'none',
					title: '没有更多数据'
				});

				// this.loadingType = 2;				
				return;
			}

			this.loadingType = 1;
			// 正常应为:
			this.getList();
		},

		methods: {
			changeEstate(){
				console.log(this.check_estate)
				this.check_estate = !this.check_estate
			},
			checked(item){
				this.id = item.id
				this.$refs.checkedModel.open()
			},
			check(){
				const _this = this
				//提交ajax
				// console.log(1111)
				var opt = {
					url: '/User/checkBusiness',
					data: {
						id:_this.id,
						check_estate:_this.check_estate?1:3,
						reason:_this.reason
					},
					success: function(res) {
						if (res.status == 1) {
							_this.$refs.checkedModel.close()
				
						} else {
				
				
						}
				
					}
				};
				this.$service.GetApi(opt) //网络	
			},
			detail(row){
				let _this=this;
				// _this.$refer.setVilit('/packageInvite/pages/businessEnter/apply_status');
				// let data = {
				// 	id:row.id
				// }
				// let callback = function(url) {
				// 	_this.$refs.popupvLogin.open()
				// }
				// _this.$refer.toUrl(callback,data)
			},
			add(){
				let _this=this;
				_this.$refer.setVilit('/packageInvite/pages/businessEnter/business_enter');
				let data = {
					
				}
				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}
				_this.$refer.toUrl(callback,data)
			},
			bind(){
				let _this=this;
				_this.$refer.setVilit('/packageInvite/pages/businessEnter/bind');
				let data = {
					
				}
				let callback = function(url) {
					_this.$refs.popupvLogin.open()
				}
				_this.$refer.toUrl(callback,data)
			},
			refresh(){
				this.getList()
			},
			getList(){
				const _this = this
				//提交ajax
				// console.log(1111)
				var opt = {
					url: '/User/businessInfoList',
					data: {
						page:++_this.curr_page
					},
					success: function(res) {
						if (res.status == 1) {
							_this.data.list=res.data.list
							_this.last_page = res.data.last_page
							_this.loadingType = 2;
							console.log(_this.last_page,22222)
						} else {
				
				
						}
				
					}
				};
				this.$service.GetApi(opt) //网络	
				
			}
			

		}
	}
</script>

<style lang="scss">
	@import "./business_list.scss";
</style>
